package com.learn.spring.bean;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Controller
@Repository("dog")
public class Dog implements IAnimal {
    private Person person;
    private String name;

    static {
        System.out.println("--------------加载dog类");
    }

    {
        System.out.println("--------------实例化dog对象");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Person getPerson() {
        return person;
    }

    @Required
    public void setPerson(Person person) {
        this.person = person;
    }

    @Override
    public void makeSound() {
        System.out.println(" W W W ");
    }

    @PostConstruct
    public void init() {
        System.out.println("dog 的初始化");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("dog 的销毁");
    }
}
